/*
 * xAPdevice.java
 *
 * Java class used to transport xAP device data
 *
 * Copyright (c) 2009 Daniel Berenguer <dberenguer@usapiens.com>
 *
 * This file is part of the jxAP project.
 *
 * OPNODE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * OPNODE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with canTracer; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 28/10/09 by Daniel Berenguer : first version
 */

package xAP;

/********************************************************************************************
 * xAPdevice class
 *
  *********************************************************************************************/
public class xAPdevice
{
   /********************************************************************************************
    * Member variables
    ********************************************************************************************/
    // xAP fields
    public String uid = "";         // xAP UID
    public String source = "";      // xAP source

   /********************************************************************************************
    * xAPdevice
    *
    * Class constructor
    *
    * 'message'     xAP message to extract the device data from
    *
    ********************************************************************************************/
    public xAPdevice(xAPmessage message)
    {
        // xAP UID
        int index = message.uid.lastIndexOf(":");

        if (index == -1)
        {
            int len = message.uid.length();
            uid = message.uid.substring(0, len-2);  // xAP 1.3 spec
        }
        else
            uid = message.uid.substring(0, index);  // xAP 1.4 spec

        // xAP source address
        index = message.source.lastIndexOf(":");

        if (index == -1)
            source = message.source;
        else
            source = message.source.substring(0, index);
    }
}
